<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich">
<h:head>
	<title>Fiap Airport Web</title>
</h:head>
<h:body>
<ui:include src="/cliente/menu.xhtml"/>
	<rich:panel header="Lista de Reserva">
	<h:form>
		<div>
			<span>Trechos:</span>
			<h:selectOneMenu value="#{compraPassagensBean.compraVO.trecho.id}" required="true">
				<f:selectItem itemValue="0" itemLabel="Selecione" />               
			    <f:selectItems value="#{compraPassagensBean.trechos}" var="trechoItem" itemValue="#{trechoItem.id}" itemLabel="#{trechoItem.descricao}"/>
			    <f:ajax listener="${compraPassagensBean.calculaValor()}" event="change" render="valorPassagem"/>
			</h:selectOneMenu>
		</div>
		<div>
			<span>Quantidade de Passagens Classe Executiva:</span>
			<h:inputText value="#{compraPassagensBean.compraVO.quantidadePassagensExecutiva}" required="true" >
				<f:ajax listener="${compraPassagensBean.calculaValor()}" event="blur" render="valorPassagem" />
				<f:validator validatorId="br.com.fiap.beans.validator.AssentosDisponiveisExecutivaValidator"/>
				<f:attribute name="compraVO" value="#{compraPassagensBean.compraVO}"/>
			</h:inputText>
		</div>
		<div>
			<span>Quantidade de Passagens Classe Econômica:</span>
			<h:inputText value="#{compraPassagensBean.compraVO.quantidadePassagensEconomica}" required="true">
				<f:ajax listener="${compraPassagensBean.calculaValor()}" event="blur" render="valorPassagem" />
				<f:validator validatorId="br.com.fiap.beans.validator.AssentosDisponiveisEconomicaValidator"/>
				<f:attribute name="compraVO" value="#{compraPassagensBean.compraVO}"/>
			</h:inputText>
		</div>
		<div>
			<span>Valor: </span>
			<h:outputText id="valorPassagem" value="#{compraPassagensBean.compraVO.valorCompra}" />
		</div>
    	<p>
			<h:commandButton action="carrinho-compras" value="Voltar" immediate="true" />
			<h:commandButton action="#{compraPassagensBean.adicionarItemSubmit()}" value="Adicionar Item" />
		</p>
	</h:form>
	</rich:panel>
</h:body>
</html>
